﻿using Domain.Flow;
using MediatR;
using U.B.DoMain.rabbitsAAA;
using U.B.ErrorCode;
using U.B.ReadApi.Command.Raddit.BW;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander.Raddit.BWHA
{
    public class GetPicACommandHander : IRequestHandler<GetPicACommand, ApiResult<PICA>>
    {
        public readonly IRepistory<PICA> _picaRepistory;
        public GetPicACommandHander(IRepistory<PICA> picaRepistory)
        {
            _picaRepistory = picaRepistory;
        }
        public Task<ApiResult<PICA>> Handle(GetPicACommand request, CancellationToken cancellationToken)
        {
            ApiResult<PICA> apiResult = new ApiResult<PICA>();
            var result = _picaRepistory.GetAll().FirstOrDefault(x => x.BatchId == request.BatchId);
            apiResult.code = Renum.显示成功;
            apiResult.Message = Renum.显示成功.ToString();
            apiResult.Data = result;
            return Task.FromResult(apiResult);
        }
    }
}
